// service统一出口
import CVRequest from './request'
import { BASE_URL, TIME_OUT } from './request/config'

// 常规接口，代理详见vite.config.ts
const cvRequest = new CVRequest({
  baseURL: '/api',
  timeout: 8000,
  // 创建实例的时候传递拦截器
  interceptors: {
    requestInterceptors: (config) => {
      const token = localStorage.getItem("token")
      if (token){
        config.headers.token = token
      }
      return config
    },
    requestInterceptorsCatch: (err) => {
      return err
    },
    responseInterceptors: (res) => {
      return res.data
    },
    responseInterceptorsCatch: (err) => {
      return err
    }
  }
})

export default cvRequest
